package test_kevin;

import java.io.File;
import java.util.ArrayList;

public class FolderUtil {
	public ArrayList<File> listFiles(File dir, boolean withSubfolders) {
		ArrayList<File> alFile = new ArrayList<File>();
		File[] files = dir.listFiles();
		if (files != null) {
			for (int i = 0; i < files.length; i++) {

				if (files[i].isDirectory() && withSubfolders) {
					alFile.addAll(listFiles(files[i], true));
				} else {
					alFile.add(files[i]);
				}
			}
		}
		return alFile;
	}

	public static void main(String args[]) {
		ArrayList<File> alfile = new FolderUtil().listFiles(new File("C:\\Dropbox\\Dropbox"), true);
		for (File f : alfile)
			System.out.println(f.getAbsolutePath());
	}
}
